package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Member;
import com.itheima.pojo.Order;
import com.itheima.service.OrderSettingListService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;


@RestController
@RequestMapping("ordersettinglist")
public class OrderSettingListController {
    @Reference
    private OrderSettingListService orderSettingListService;

    //新增检查组
    @RequestMapping("/add")
    public Result add(@RequestBody Member member, Integer[] setmealIds) throws Exception {
        Result result = null;
            result = orderSettingListService.add(member, setmealIds);
        return result;//返回结果
    }

    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        PageResult pageResult = orderSettingListService.pageQuery(queryPageBean);
        return pageResult;
    }

    @RequestMapping("/confirmOrder")
    public Result confirmOrder(Integer id) {
        try {
            orderSettingListService.confirmOrder(id);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "确认预约失败");//新增失败
        }
        return new Result(true, "确认预约成功");//新增成功
    }

    //cancelOrder
    @RequestMapping("/cancelOrder")
    public Result cancelOrder(Integer id) {
        try {
            orderSettingListService.cancelOrder(id);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "取消预约失败");//新增失败
        }
        return new Result(true, "取消预约成功");//新增成功
    }
}
